@extends('layouts.app')
<style>
    #d2{
        display: none;
    }
</style>
@section('content')
    <span class="btn btn-warning pull-right" lay-submit lay-filter="login" id="span1">列表</span>
    <span class="btn btn-warning pull-right" lay-submit lay-filter="login" id="span2">添加</span>
    <br><br>
    <div id="d1">
        <form class="well form-search" method="post">
            发布时间<input type="text" name="start_time" class="js-date" value="" style="width: 80px;" autocomplete="off">-
            <input autocomplete="off" type="text" class="js-date" name="end_time" value="" style="width: 80px;"> 关键字
            <input type="text" name="keyword" style="width: 200px;" value="" placeholder="请输入关键字...">
            <button class="btn btn-primary">搜索</button>
        </form>
        <table class="layui-table">
            <thead>
            <tr>
                <th>
                    排序
                </th>
                <th>
                    ID
                </th>
                <th>
                    靓号
                </th>
                <th>
                    所需点数
                </th>
                <th>
                    位数
                </th>
                <th>
                    状态
                </th>
                <th>
                    发布时间
                </th>
                <th>
                    购买人
                </th>
                <th>
                    购买时间
                </th>
                <th>
                    操作
                </th>
            </tr>
            </thead>
            <tbody>
                @foreach($info as $key=>$r)
                <tr>
                    <td>{{$r->serial}}</td>
                    <td>{{$r->id}}</td>
                    <td>{{$r->good_number}}</td>
                    <td>{{$r->good_needcoin}}</td>
                    <td>{{$r->good_count}}</td>
                    <td id="num_status">@if($r->good_status =='1')未出售@else已出售@endif</td>
                    <td>{{$r->good_addtime}}</td>
                    <td>@if($r->good_user==''||$r->good_userid=='')未出售@else{{$r->good_user}}({{$r->good_userid}})@endif</td>
                    <td>@if($r->good_needtime=='1')未出售@else{{$r->good_needtime}}@endif</td>
                    <td id="num_cz"><a href="number_delete/{{$r->id}}">删除</a>|<a href="number_edit/{{$r->id}}">编辑</a>|<a href="number_stop/{{$r->id}}">停售</a></td>
                </tr>
                @endforeach
            </tbody>
        </table>
    </div>
    <div id="d2">
        <form action="{{url('number_add')}}" method="post">
            {{csrf_field()}}
            <label class="login-title" for="username">序号</label>
            <div class="layui-form-item">
                <div class="layui-input-inline login-inline">
                    <input type="text" name="serial" lay-verify="required" placeholder="请输入ID" autocomplete="off" class="layui-input" value="0">
                </div>
            </div>
            <label class="login-title" for="username">靓号</label>
            <div class="layui-form-item">
                <div class="layui-input-inline login-inline">
                    <input type="text" name="good_number" lay-verify="required" id="c_time" autocomplete="off" class="layui-input" maxlength="6">*最长6位
                </div>
            </div>
            <label class="login-title" for="username">所需钻石</label>
            <div class="layui-form-item">
                <div class="layui-input-inline login-inline">
                    <input type="text" name="good_needcoin" lay-verify="required" id="c_time" autocomplete="off" class="layui-input" >
                </div>
            </div>
            <input type="submit" value="添加" class="btn btn-warning pull-right" lay-submit lay-filter="login">
            <span class="btn btn-warning pull-right" lay-submit lay-filter="login"><a href="{{url('number_index')}}">返回</a></span>
        </form>
    </div>
@endsection
<script src="jquery.js"></script>
<script>
    $(document).on("click","#span2",function(){
        if($("#d2").css("display")=="none"){
            $("#d2").css("display","block");
            $("#d1").css("display","none");
        }else{
            $("#d2").css("display","none");
            $("#d1").css("display","block");
        }
    })
    $(document).on("click","#span1",function(){
        if($("#d1").css("display")=="none"){
            $("#d1").css("display","block");
            $("#d2").css("display","none");
        }else{
            $("#d1").css("display","none");
            $("#d2").css("display","block");
        }
    })
    $(function(){
        if($("#num_status").html("已出售")){
            $("#num_cz").html("");
        }
    })
</script>